Hello, if(!open(mn)) read(fullName(mn),false)
sdauphin - Thu Sep 16 08:06:55 EDT 2010 |
Re: Read() causing Exception error With Module m |
Re: Read() causing Exception error |
Re: Read() causing Exception error SystemAdmin - Thu Sep 16 08:32:43 EDT 2010
@Pekka :
// for each link arriving on o and following rlm link module
for lref in o <- "rlm" do {
// Get the source module name
mn = source(lref)
// opens the module in read mode and invisible if it is not open
if(!open(mn)) {
read(fullName(mn),false)
}
}
|
Re: Read() causing Exception error sdauphin - Thu Sep 16 09:03:29 EDT 2010
@Pekka :
// for each link arriving on o and following rlm link module
for lref in o <- "rlm" do {
// Get the source module name
mn = source(lref)
// opens the module in read mode and invisible if it is not open
if(!open(mn)) {
read(fullName(mn),false)
}
}
For me there are two plausible reasons that your code crashes with an exception: a) Your ModName_ variable memory got corrupted (Could not see how or why? Eventually by really messing up the DOORS heap) b) Your Object variable memory got corrupted (more plausible, maybe the module is closed, or the edit mode changed?) You probably did this in some part of the code, that you have not posted, or at least I could not spot a reason. In most cases it is so hard to find bugs, since we look at the wrong place. Can you post a more complete code example? Regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Read() causing Exception error Mathias Mamsch - Thu Sep 16 09:45:00 EDT 2010 Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS I am attaching the full script as a zip file (~ 600 lines). There is a small readme file, I hope it contains enough information. The extract is coming from function initLinkedObjectList in objectModified.dxl, but if I understand you well, the root cause of the problem may be anywhere, right ? I hope you can point me to weak code statements. Best regards, Servanne. Attachments attachment_14532309_Reuse_DXL_Scripts.zip |
Re: Read() causing Exception error sdauphin - Thu Sep 16 10:57:26 EDT 2010
Two things come to my eye when skimming through your code:
for l in o1 -> rlmn do {
delete(l)
}
Skip sk = create(); for l in o1->rlmn do { put (sk, l,l) }; for l in sk do delete l
objectModified.dxl:280 -> void initLinkedObjectList (DBE listDBE, Object o)
...
{code}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Read() causing Exception error Mathias Mamsch - Thu Sep 16 12:14:36 EDT 2010
Two things come to my eye when skimming through your code:
for l in o1 -> rlmn do {
delete(l)
}
Skip sk = create(); for l in o1->rlmn do { put (sk, l,l) }; for l in sk do delete l
objectModified.dxl:280 -> void initLinkedObjectList (DBE listDBE, Object o)
...
{code}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Read() causing Exception error Mathias Mamsch - Thu Sep 16 12:14:36 EDT 2010
Two things come to my eye when skimming through your code:
for l in o1 -> rlmn do {
delete(l)
}
Skip sk = create(); for l in o1->rlmn do { put (sk, l,l) }; for l in sk do delete l
objectModified.dxl:280 -> void initLinkedObjectList (DBE listDBE, Object o)
...
{code}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Read() causing Exception error sdauphin - Thu Sep 16 09:03:29 EDT 2010
@Pekka :
// for each link arriving on o and following rlm link module
for lref in o <- "rlm" do {
// Get the source module name
mn = source(lref)
// opens the module in read mode and invisible if it is not open
if(!open(mn)) {
read(fullName(mn),false)
}
}
But its possible the default view in that module has layout code that causes the crash. Before you "read", ack the fullname. When you find out which module triggers the crash, try opening it first manually then via a DXL read statement. You may also want to split the fullname up from the read: Name = fullName(mn). If there is an issue with the view, you can bypass it with: read(fullName(mn), false, true) which loads the 'standard' view.
|
Re: Read() causing Exception error llandale - Thu Sep 16 13:11:46 EDT 2010
I have tried the different suggestions :
Let me describe one scenario that crashes consistently :
I have indeed some DXL attributes in my views, with cross-references between pool and project modules (generated with traceability wizard, then converted to DXL attributes). I have noticed something weird : when I enable the TRACE variable and display the status of the project modules (if (TRACE) print "Open = " open(mn) "\n"), I can see that the project modules are already "open" (in background) on the first run. On the second run, they are not opened, since I have closed them at the end of the first run with the closeInvisibleModules function. Why are they open from the start ? It is due to the DXL attributes ? Nevertheless, if I open all the modules (pool + projects) in exclusive before trying to make changes, I still get a crash, even if it happens a bit later ... Best regards, Servanne. |
Re: Read() causing Exception error sdauphin - Thu Sep 16 14:07:40 EDT 2010
Let me describe one scenario that crashes consistently :
I have indeed some DXL attributes in my views, with cross-references between pool and project modules (generated with traceability wizard, then converted to DXL attributes). I have noticed something weird : when I enable the TRACE variable and display the status of the project modules (if (TRACE) print "Open = " open(mn) "\n"), I can see that the project modules are already "open" (in background) on the first run. On the second run, they are not opened, since I have closed them at the end of the first run with the closeInvisibleModules function. Why are they open from the start ? It is due to the DXL attributes ? Nevertheless, if I open all the modules (pool + projects) in exclusive before trying to make changes, I still get a crash, even if it happens a bit later ... Best regards, Servanne.
I have made some progress this morning : objects_to_synchronize_skip = linked_objects_skip modules_to_synchronize_skip = linked_modules_skip
int i = 0
Object temp_o
for temp_o in linked_objects_skip do {
put (objects_to_synchronize_skip, i++, temp_o)
}
i = 0
ModName_ tmod
for tmod in linked_modules_skip do {
put (modules_to_synchronize_skip, i++, tmod)
}
|
Re: Read() causing Exception error sdauphin - Fri Sep 17 05:48:51 EDT 2010
I have made some progress this morning : objects_to_synchronize_skip = linked_objects_skip modules_to_synchronize_skip = linked_modules_skip
int i = 0
Object temp_o
for temp_o in linked_objects_skip do {
put (objects_to_synchronize_skip, i++, temp_o)
}
i = 0
ModName_ tmod
for tmod in linked_modules_skip do {
put (modules_to_synchronize_skip, i++, tmod)
}
I'm posting the code here for more convenience :
/**
* Closes all the modules opened by a script, so which are not visible.
*/
void closeInvisibleModules(){
Module m
// for each open module in the database (with read access from the current user)
for m in database do {
// if m is a formal module and is not visible, close it
if(type(m)=="Formal" && !isVisible(m)) close(m,false)
}
}
|
Re: Read() causing Exception error sdauphin - Fri Sep 17 05:51:22 EDT 2010 I'm posting the code here for more convenience :
/**
* Closes all the modules opened by a script, so which are not visible.
*/
void closeInvisibleModules(){
Module m
// for each open module in the database (with read access from the current user)
for m in database do {
// if m is a formal module and is not visible, close it
if(type(m)=="Formal" && !isVisible(m)) close(m,false)
}
}
Servanne, you have to be careful with closing modules. Closing a module will invalidate all object and module handles and any access to them will lead to a crash. So
for module in database do { ... close m ... } // ouch!
Skip sk = create();
for module in database do { ... put (sk, module, module) };
for module in sk do close module;
delete sk
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Read() causing Exception error sdauphin - Fri Sep 17 05:48:51 EDT 2010
I have made some progress this morning : objects_to_synchronize_skip = linked_objects_skip modules_to_synchronize_skip = linked_modules_skip
int i = 0
Object temp_o
for temp_o in linked_objects_skip do {
put (objects_to_synchronize_skip, i++, temp_o)
}
i = 0
ModName_ tmod
for tmod in linked_modules_skip do {
put (modules_to_synchronize_skip, i++, tmod)
}
Assigning a Skip to a Skip is creating an alias; it does NOT make a copy like you do in your changed manual code.
void PrintSkip(string Label, Skip skp)
{ string Data
for Data in skp do
{ print Label "\t" Data "\n"
}
}
Skip skp1 = createString()
put(skp1, "1-1", "1-1")
put(skp1, "1-2", "1-2")
Skip skp2 = createString()
put(skp2, "2-1", "2-1")
PrintSkip("skp1", skp1)
PrintSkip("skp2", skp2)
Skip skp3 = skp2 // Makes alias
PrintSkip("skp3", skp3) // prints 2-1
put(skp3, "3-1", "3-1")
PrintSkip("skp2", skp2) // prints 2-1; 3-1
Skip skp4 = skp1
skp1 = skp2
PrintSkip("skp1", skp1) // prints 2-1; 3-1
delete(skp2)
delete(skp4) // originally skp1
skp1 1-1 skp1 1-2 skp2 2-1 skp3 2-1 skp2 2-1 skp2 3-1 skp1 2-1 skp1 3-1
|